<?php

class Lib_Session {
    private $CI;
    
    public function __construct() {
        $this->CI =& get_instance();
    }
    
    // vytvori session
    public function setSession($dbUser) {
         $session_data = array(
            'logged' => 1,
             'fk_role' => $dbUser->fk_roles,
            'username' => $dbUser->email,
             'id' => $dbUser->id,
            'firstname' => $dbUser->firstname,
            'lastname' => $dbUser->lastname,
            'year' => $dbUser->year
        );
         
        $this->CI->session->set_userdata($session_data);
    }
    
    // zmaze session
    public function unsetSession() {
         $this->CI->session->sess_destroy();
    }
    
    
    // vrati, ci je uzivatel prihlaseny alebo nie
    public function isLogged() {
        return $this->CI->session->userdata('logged') == 1;
    }
}

?>
